--[[ Copyright 2012, Chris Ho                               ]]--
--[[ MIT License (Please read the LICENSE file for details) ]]--

-- Crinkle's Persona TEST SCRIPT
-- Conventions: always end statements with semicolon
-- Global variables are all uppercase
-- Functions are CamelCase, with first letter capitalized
--
-- To use this as a Homunculus AI, put it in USER_AI and type "/hoai"
-- To use this as a Mercenary AI, put it in USER_AI and type "/merai"
-- To enable file logging, type "/traceai" (to "TraceAI.txt" in iRO install path)

-- -- -- -- -- -- -- --

ROOT = "./";
PATH = ROOT .. "AI/USER_AI/";
--PATH = ROOT;

function Use(_name)
  require(PATH .. _name);
end

package.path = PATH .. "?.lua;" .. package.path;
Use("Core");

LOG_LEVEL = LOG_DEBUG;

TRANQUILITY = 6.0;
RESILIENCE = 2.0;
LEASH = 15;
VISIBILITY = 20;

FRIENDS_FILE = PATH .. "friends.txt";

PERSONALITY_ARCHER = PATH .. "archer/Archer.lua";
PERSONALITY_LANCER = PATH .. "lancer/Lancer.lua";
PERSONALITY_SWORDMAN = PATH .. "fencer/Fencer.lua";
PERSONALITY_HOMUNCULUS = PATH .. "homunculus/Homunculus.lua";

MERCENARIES = {};
MERCENARIES[LANCER01] = PATH .. "lancer/l01.lua";
MERCENARIES[LANCER02] = PATH .. "lancer/l02.lua";
MERCENARIES[LANCER03] = PATH .. "lancer/l03.lua";
MERCENARIES[LANCER04] = PATH .. "lancer/l04.lua";
MERCENARIES[LANCER05] = PATH .. "lancer/l05.lua";
MERCENARIES[LANCER06] = PATH .. "lancer/l06.lua";
MERCENARIES[LANCER07] = PATH .. "lancer/l07.lua";
MERCENARIES[LANCER08] = PATH .. "lancer/l08.lua";
MERCENARIES[LANCER09] = PATH .. "lancer/l09.lua";
MERCENARIES[LANCER10] = PATH .. "lancer/l10.lua";
MERCENARIES[ARCHER01] = PATH .. "archer/a01.lua";
MERCENARIES[ARCHER02] = PATH .. "archer/a02.lua";
MERCENARIES[ARCHER03] = PATH .. "archer/a03.lua";
MERCENARIES[ARCHER04] = PATH .. "archer/a04.lua";
MERCENARIES[ARCHER05] = PATH .. "archer/a05.lua";
MERCENARIES[ARCHER06] = PATH .. "archer/a06.lua";
MERCENARIES[ARCHER07] = PATH .. "archer/a07.lua";
MERCENARIES[ARCHER08] = PATH .. "archer/a08.lua";
MERCENARIES[ARCHER09] = PATH .. "archer/a09.lua";
MERCENARIES[ARCHER10] = PATH .. "archer/a10.lua";
MERCENARIES[SWORDMAN01] = PATH .. "fencer/f01.lua";
MERCENARIES[SWORDMAN02] = PATH .. "fencer/f02.lua";
MERCENARIES[SWORDMAN03] = PATH .. "fencer/f03.lua";
MERCENARIES[SWORDMAN04] = PATH .. "fencer/f04.lua";
MERCENARIES[SWORDMAN05] = PATH .. "fencer/f05.lua";
MERCENARIES[SWORDMAN06] = PATH .. "fencer/f06.lua";
MERCENARIES[SWORDMAN07] = PATH .. "fencer/f07.lua";
MERCENARIES[SWORDMAN08] = PATH .. "fencer/f08.lua";
MERCENARIES[SWORDMAN09] = PATH .. "fencer/f09.lua";
MERCENARIES[SWORDMAN10] = PATH .. "fencer/f10.lua";

HOMUNCULI = {};
HOMUNCULI[LIF] = PATH .. "homunculus/lif.lua";
HOMUNCULI[AMISTR] = PATH .. "homunculus/amistr.lua";
HOMUNCULI[FILIR] = PATH .. "homunculus/filir.lua";
HOMUNCULI[VANILMIRTH] = PATH .. "homunculus/vanilmirth.lua";
HOMUNCULI[LIF2] = PATH .. "homunculus/lif-2.lua";
HOMUNCULI[AMISTR2] = PATH .. "homunculus/amistr-2.lua";
HOMUNCULI[FILIR2] = PATH .. "homunculus/filir-2.lua";
HOMUNCULI[VANILMIRTH2] = PATH .. "homunculus/vanilmirth-2.lua";
HOMUNCULI[LIF_H] = PATH .. "homunculus/lif-H.lua";
HOMUNCULI[AMISTR_H] = PATH .. "homunculus/amistr-H.lua";
HOMUNCULI[FILIR_H] = PATH .. "homunculus/filir-H.lua";
HOMUNCULI[VANILMIRTH_H] = PATH .. "homunculus/vanilmirth-H.lua";
HOMUNCULI[LIF_H2] = PATH .. "homunculus/lif-H2.lua";
HOMUNCULI[AMISTR_H2] = PATH .. "homunculus/amistr-H2.lua";
HOMUNCULI[FILIR_H2] = PATH .. "homunculus/filir-H2.lua";
HOMUNCULI[VANILMIRTH_H2] = PATH .. "homunculus/vanilmirth-H2.lua";


--[[ GetV Stub (for testing) ]]--
function GetV(_key, _id)
  if (_key == V_POSITION) then return 10, 10 end
  return 0;
end
--[[ GetTick Stub (for testing) ]]--
function GetTick()
  return 0;
end
--[[ TraceAI Stub (for testing) ]]--
function TraceAI(_text)
  print(_text);
end
--[[ GetMsg Stub (for testing) ]]--
function GetMsg(_id)
  return { NONE_CMD };
end
--[[ GetResMsg Stub (for testing) ]]--
function GetResMsg(_id)
  return { NONE_CMD };
end
--[[ GetActors Stub (for testing) ]]--
function GetActors()
  return { 123 };
end
--[[ IsMonster Stub (for testing) ]]--
function IsMonster()
  return true;
end

-- Test load each main file.
Initialize(0, PERSONALITY_ARCHER);
Initialize(0, PERSONALITY_LANCER);
Initialize(0, PERSONALITY_SWORDMAN);
Initialize(0, PERSONALITY_HOMUNCULUS);

Initialize(0, MERCENARIES[LANCER02]);
Initialize(0, MERCENARIES[ARCHER02]);
Initialize(0, MERCENARIES[SWORDMAN02]);

-- Test a single AI sequence.
Survey();
Decide();
Act();
Reflect();
